package com.cntcdt.api.db.dao;

import java.util.List;

import com.cntcdt.api.db.dao.base.UserMoneyHistoryDaoBase;
import com.cntcdt.api.db.model.UserMoneyHistoryModel;

/**
 * 这是cdt_user_money_history的Dao实现类
 */
public class UserMoneyHistoryDao extends UserMoneyHistoryDaoBase {
	/**
	 * UserMoneyHistoryDao对象
	 */
	private static UserMoneyHistoryDao instance = new UserMoneyHistoryDao();

	/**
	 * 默认构造方法
	 */
	private UserMoneyHistoryDao() {
	}

	/**
	 * 获得对象实例
	 */
	public static UserMoneyHistoryDao getInstance() {
		return instance;
	}

	/**
	 * 根据用户id查询消费记录
	 * 
	 * @param userId
	 * @param sortTime
	 * @return
	 */
	public List<UserMoneyHistoryModel> findByUserId(int userId, int sortTime) {
		sortTime = sortTime * 20;
		String sql = "select * from " + TABLE + " where userId = ? order by addTime desc limit ?,20";
		Object[] paramObjs = { userId, sortTime };
		List<UserMoneyHistoryModel> modelList = this.queryModelList(sql, paramObjs);
		return modelList;
	}
}
